﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Clueless
{
    public partial class endOfTurn : Form
    {
        public event EventHandler<OptionSelectedEventArgs> OptionSelected;
        public endOfTurn()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            SendOptionSelectedMessage("Suggest");
        }

        private void endTurnButton_Click(object sender, EventArgs e)
        {
            SendOptionSelectedMessage("End Turn");
        }

        private void accusationButton_Click(object sender, EventArgs e)
        {
            SendOptionSelectedMessage("Accuse");
        }


        /// <summary>
        /// Start Trun
        /// </summary>
        /// <param name="s"></param>
        private void SendOptionSelectedMessage(String s)
        {
            this.Hide();
            OptionSelectedEventArgs args = new OptionSelectedEventArgs();
            args.option = s;
            OnOptionSelectedMessage(args);
        }
        protected virtual void OnOptionSelectedMessage(OptionSelectedEventArgs e)
        {
            EventHandler<OptionSelectedEventArgs> handler = OptionSelected;
            if (handler != null)
            {
                handler(this, e);
            }
        }

        private delegate void BoolDelegate(bool p);
        private delegate void DoubleBoolDelegate(bool p, bool b);
        public void IsHall(bool p, bool b)
        {
            if (suggestionButton.InvokeRequired)
                suggestionButton.Invoke(new DoubleBoolDelegate(IsHall), p, b);
            else
            {
                suggestionButton.Enabled = !p;
                endTurnButton.Enabled = !b;
            }
        }
    }

    public class OptionSelectedEventArgs : EventArgs
    {
        public String option { get; set; }
    }
}
